/*======================================================================*\
|| #################################################################### ||
|| # vBExperience 4.1                                                 # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright 2006-2011 Marius Czyz / Phalynx. All Rights Reserved. # ||
|| #################################################################### ||
\*======================================================================*/

This document is an addendum to the readme of vBExperience 4.0 and it's purpose is to explain the hooks needed to enable own custom data providers. Please study the product "product_vbexperience_cdp_example.xml" which contains a Custom Data Provider on base of attachmentviews.
In the sample is "YOURPROVIDER" named "xpcdp". Replace that with your own unique string.


Database
	- Setup
		For your own custom data provider you will need to setup the database:
		
		[CODE]
			require_once('./includes/install_xperience.php');		
			CheckStatsField("points_misc_YOURPROVIDER");
		[/CODE]

		On uninstall, use the following:
		[CODE]
			require_once('./includes/install_xperience.php');		
			DropField("points_misc_YOURPROVIDER");
		[/CODE]

Code Hooks
	- xperience_calcdata_begin
		Fires at the beginning of the calculation process. A good entry to modify f.e. the array $IgnorePluginForums
	
	- xperience_calcdata_summaries
		A hook to change data in array $xperience before it's get calculated
	
	- xperience_calcdata_end
		Fires at the very end of the calculation process.

	- xperience_calcdata
	- xperience_calcdata_misc
	- xperience_calcdata_post
	- xperience_calcdata_thread
	- xperience_calcdata_user

		This hook can be used to calculate own data and add it to existing main provider count_misc
		
		To add points to misc:
		[CODE]
			$xperience['count_misc'] += $xperience['count_misc_YOURPROVIDER'];
		[/CODE]

	
		Beside count_misc/points_misc, you can also use the other main provider:
		- count_user
		- count_post
		- count_thread
	
	
	- xperience_memberprofile
		You will have to pull the data from the database and prepare it:
		[CODE]
			global $vbphrase;
			$xperience['points_misc_YOURPROVIDER'] = vb_number_format($stat_q['points_misc_YOURPROVIDER']);
			
			$templater = vB_Template::create('xperience_YOURPROVIDER_profile');
			$templater->register('xperience', $xperience);
			$block_data['xperience_points_misc_tpl'] .= $templater->render(); 
		[/CODE]
		
		You can use these variables to hook in the place you need:
		$block_data['xperience_points_user_tpl']
		$block_data['xperience_points_thread_tpl']
		$block_data['xperience_points_post_tpl']
		$block_data['xperience_points_misc_tpl']
		
		
		
	- xperience_earn_misc
	- xperience_earn_post
	- xperience_earn_thread
	- xperience_earn_user
		These hooks are used to display earn points to the user
		Use this call:
		[CODE]
			$xperience['earnpoints'] .= ResolveAssociation("xperience_points_YOURPROVIDER", "", "points_misc_YOURPROVIDER");
		[/CODE]
		
		Syntax: ResolveAssociation(Phrase, TableName (optional), Column with points)
		
		"xperience_points_YOURPROVIDER" is the name of the setting. If your CDP is using a table you can check that also by adding the name of the table as a second parameter to ResolveAssociation.